function Graph () {
  // 属性
  this.vertexes = [] // 存储顶点
  this.adjList = new Map() // 存储边
}
// 添加方法
Graph.prototype.addVertex = function (v) {
  this.vertexes.push(v)
  this.adjList.set(v, [])
}
Graph.prototype.addEdge = function (v, w) {
  this.adjList.get(v).push(w)
  this.adjList.get(w).push(v)
}
Graph.prototype.toString = function () {
  var resultStr = ""
  for (var i = 0; i < this.vertexes.length; i++) {
    resultStr += this.vertexes[i] + "->"
    var adj = this.adjList.get(this.vertexes[i])
    for (var j = 0; j < adj.length; j++) {
      resultStr += adj[j] + " "
    }
    resultStr += "\n"
  }
  return resultStr
}
// 测试代码
var graph = new Graph()

// 添加顶点
var myVertexes = ["A", "B", "C", "D", "E", "F", "G", "H", "I"]
for (var i = 0; i < myVertexes.length; i++) {
  graph.addVertex(myVertexes[i])
}

// 添加边
graph.addEdge('A', 'B');
graph.addEdge('A', 'C');
graph.addEdge('A', 'D');
graph.addEdge('C', 'D');
graph.addEdge('C', 'G');
graph.addEdge('D', 'G');
graph.addEdge('D', 'H');
graph.addEdge('B', 'E');
graph.addEdge('B', 'F');
graph.addEdge('E', 'I');
console.log(graph)